<template>
  <el-table
    ref="tableData"
    v-loading="listLoading"
    :data="tableData"
    border
    highlight-current-row
    style="width: 99%; margin-top: 10px"
    height="600px"
    @row-dblclick="updateTable"
  >
    <el-table-column type="selection" width="50" align="center" />
    <el-table-column label="序号" width="80" align="center">
      <template slot-scope="scope">
        <p>{{ scope.$index + 1 }}</p>
      </template>
    </el-table-column>
    <el-table-column label="角色" align="center" width="150">
      <template slot-scope="scope">
        <p>{{ scope.row.name }}</p>
      </template>
    </el-table-column>
    <el-table-column label="角色编号" align="center" width="150">
      <template slot-scope="scope">
        <p>{{ scope.row.code }}</p>
      </template>
    </el-table-column>
    <el-table-column label="所属公司" align="center" width="150">
      <template slot-scope="scope">
        <p>{{ scope.row.companyDTO.name }}</p>
      </template>
    </el-table-column>
    <el-table-column label="所属机构" align="center" width="150">
      <template slot-scope="scope">
        <p>{{ scope.row.organizationDTO.name }}</p>
      </template>
    </el-table-column>
    <el-table-column label="启用" align="center" width="150">
      <template slot-scope="scope">
        <el-tag size="mini" type="success">
          {{ scope.row.status === 1 ? '启用' : '停用' }}
        </el-tag>
      </template>
    </el-table-column>
    <el-table-column label="操作" align="center" width="auto">
      <template slot-scope="scope">
        <el-button type="primary" size="small" @click="copyTable(scope.row)">复制</el-button>
        <el-button size="small" @click="updateTable(scope.row)">编辑</el-button>
        <el-button size="small" type="danger" @click="removeTable(scope.row)">删除</el-button>
        <el-button size="small" type="warning" @click="checkPermission(scope.row)">查看权限</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>

export default {
  name: 'MainTable',
  props: {
    tableData: {
      require: true,
      type: Array,
      default: function() {
        return { message: '没有传递.' }
      }
    },
    listLoading: {
      require: true,
      type: Boolean,
      default: function() {
        return { message: '没有传递.' }
      }
    }
  },
  methods: {
    copyTable(row) {
      this.$emit('copyTable', row)
    },
    updateTable(row) {
      this.$emit('updateTable', row)
    },
    removeTable(row) {
      this.$emit('removeTable', row)
    },
    checkPermission(row) {
      this.$emit('checkPermission', row)
    }

  }
}
</script>

<style scoped lang="scss">

</style>
